import { useReactive } from "ahooks";
import { useModel } from "umi";
import { useEffect } from "react";
import compress from "gql-compress";

const useAllCommodities = () => {
    const { graphqlFetch } = useModel("global");

    const state = useReactive({
        commoditiesLoading: false,
        commodities: [],
    });

    const loadAllCommodities = async ({ first, offset }) => {
        state.commoditiesLoading = true;
        // let res = await graphqlFetch({
        //     query,
        //     variables: {},
        // });
        // let commodities = res?.a?.nodes || [];
        let commodities = [0, 1, 3, 3, 3, 3, 3]
        state.commodities = commodities;
        state.commoditiesLoading = false;
        // return commodities;
    };

    return { ...state, loadAllCommodities };
};

const query = compress(``);

export default useAllCommodities;
